﻿<script type="text/javascript" language="javascript">
function ContentLookupListCallBackWrapper%JSLINK%(xml)
{
    if(xml==null) return; 
    var ctx=document.getElementById('%LISTBOX%');
	var xmlDoc;
	if(document.implementation && document.implementation.createDocument)
	{
		xmlDoc=(new DOMParser()).parseFromString(xml, "text/xml");
	}
	else
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.loadXML(xml);
	}
	var entities=xmlDoc.documentElement;
	for(x=0;x<entities.childNodes.length;x++)
	{
		var entity=entities.childNodes[x];
		var displayText =entity.getAttribute("DisplayText");
		if(displayText.length > %DISPLAYTRIMLENGTH%)
		{
		    displayText = displayText.substring(0,%DISPLAYTRIMLENGTH%);
		}
		var keyValue =entity.getAttribute("Key");
		var newPos = ctx.length;
		ctx.options[newPos] = new Option(keyValue + "=" + displayText,keyValue);
	}
    ContentLookupList_OnChange%JSLINK%();
 }
 
function ContentLookupList_Clear%JSLINK%()
{
    var ctx=document.getElementById('%LISTBOX%');
    ctx.options.length=0;
    ContentLookupList_OnChange%JSLINK%();
}

function ContentLookupList_Delete%JSLINK%()
{
    var ctx=document.getElementById('%LISTBOX%');
    for (var i=0; i < ctx.options.length; i++)
    {
        if (ctx.options[i].selected)
        {
            ctx.options[i]=null;
        }
    }
    ContentLookupList_OnChange%JSLINK%();
}

function ContentLookupList_OnChange%JSLINK%()
{
    var ctx=document.getElementById('%LISTBOX%');
    var ctxData=document.getElementById('%LISTBOXDATA%');
    var newValue='';
    for (var i=0; i < ctx.options.length; i++)
    {
        newValue +=ctx.options[i].value;
        newValue+='~';
    }
    ctxData.value=newValue;
}
function ContentLookupList_Dialog%JSLINK%()
{

    var sDialogUrl = '%DIALOGURL%';
    var sFeatures='resizable: yes; status: no; scroll: no; help: no; center: yes; dialogWidth : 575px; dialogHeight : 500px;';
    var rv=commonShowModalDialog(sDialogUrl, sFeatures,ContentLookupListCallBackWrapper%JSLINK%);
}
</script>